<div class="fsh-pop">
    <div id="add_form" class="layui-form" lay-filter="add_form">
        <div class="layui-form-item">
            <input type="hidden" name="menu_id"/>
            <label class="layui-form-label"><i>*</i>名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" lay-verify="required" placeholder="请输入关键字" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><i>*</i>别名</label>
            <div class="layui-input-block">
                <input name="menuKey" maxlength="20" lay-verify="required" placeholder="请输入内容" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" id="menu-pid-select">
            <label class="layui-form-label"><i>*</i>上级名称</label>
            <div class="layui-input-block">
                <input type="text" id="selectID2" lay-filter="selectID" class="layui-input">
                <select id="selectID" lay-filter="parent" name="pid">

                </select>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    layui.use(['form', 'treeselect'], function () {
        var form = layui.form;var $ = layui.jquery;
        var originData = JSON.parse($('<div>').html('<%=$data%>').text());
        if (originData && originData.menu_id) {//如果是修改,则不出现选择上级下拉菜单
            console.log(originData);
            form.val('add_form', originData);
            $("#menu-pid-select").html("");
        } else {
            $.ajax({
                url: context + '/api/sysMenu/list',
                dataType: 'json',
                type: 'get',
                success: function (data) {
                    if (data != undefined && data != null && data != "") {
                        $('#selectID').html("");
                        var list = data.data;
                        var html = "<option value=''>请选择上级角色</option>";
                        for (var i = 0; i < list.length; i++) {
                            html += "<option value=" + list[i]["menu_id"] + ">" + list[i]["title"] + "</option>";
                        }
                        $("#selectID").append(html);
                        form.render("select");
                    }
                }
            });
        }
    });

</script>